package by.admonko.universaltesting.services;

import by.admonko.universaltesting.datamodel.Answer;
import by.admonko.universaltesting.datamodel.AnswerResult;
import by.admonko.universaltesting.datamodel.Question;
import by.admonko.universaltesting.datamodel.Test;
import by.admonko.universaltesting.datamodel.TestResult;
import by.admonko.universaltesting.datamodel.UserGroup;
import by.admonko.universaltesting.datamodel.UserTbl;
import by.admonko.universaltesting.datamodel.enums.OutMethod;

public abstract class GenerateDataUtils {

	public static UserTbl getRandUser() {
		UserTbl user = new UserTbl();
		user.setIsAdmin(RandomUtils.randomBoolean());
		user.setOnlyOwnerUpd(RandomUtils.randomBoolean());
		user.setOwner(null);
		user.setUserGroup(null);
		user.setUserName(RandomUtils.randomString("user-"));
		user.setUserPasswd(RandomUtils.randomInteger());

		return user;

	}

	public static UserGroup getRandGroup() {
		final UserGroup group = new UserGroup();
		group.setOnlyOwnerUpd(RandomUtils.randomBoolean());
		group.setOwner(null);
		group.setUserGroupName(RandomUtils.randomString("Group-"));
		return group;
	}

	public static AnswerResult getAnswerRes() {
		final AnswerResult answerRes = new AnswerResult();
		answerRes.setAnsChek(RandomUtils.randomBoolean());
		return answerRes;
	}

	public static Test getTest() {
		Test test = new Test();
		test.setOnlyOwnerUpd(RandomUtils.randomBoolean());
		;
		test.setOutMethod(OutMethod.LIFO);
		// test.setOwner(owner);
		test.setQuestEntry(RandomUtils.randomInteger());
		test.setTestName(RandomUtils.randomString());
		test.setTestTime(RandomUtils.randomLong());
		// test.setUserGroup(getUserGroupSet());
		return test;

	}

	public static UserGroup getUserGroup() {

		UserGroup userGroup = new UserGroup();
		userGroup.setOnlyOwnerUpd(RandomUtils.randomBoolean());
		userGroup.setOwner(null);
		userGroup.setUserGroupName(RandomUtils.randomString("UsGrName-"));

		return userGroup;
	}

	public static Question getQuestion() {
		Question quest = new Question();
		quest.setHandAnswer(RandomUtils.randomBoolean());
		quest.setQuestMedia(RandomUtils.randomString("url-"));
		quest.setQuestText(RandomUtils.randomString("Questin - "));
		quest.setQuestTime(RandomUtils.randomLong());
		quest.setTest(null);
		return quest;
	}

	public static Answer getAnswer() {
		Answer answer = new Answer();
		answer.setAnsMedia(RandomUtils.randomString("url-"));
		answer.setAnsRating(RandomUtils.randomInteger());
		return answer;
	}

	public static TestResult getTestResult(Test test, UserGroup userGroup,
			UserTbl user) {

		TestResult testResult = new TestResult();
		testResult.setOwnerNote("");
		testResult.setTest(test);
		testResult.setTestDate(RandomUtils.randomDate());
		testResult.setTestRaiting(RandomUtils.randomInteger(0, 10));
		testResult.setUser(user);
		testResult.setUserGroup(userGroup);
		return testResult;
	}
}
